package sessionbeans;

import javax.el.ELContext;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

@ManagedBean
public class NavegacaoMB {
	
	public String categoriaProblema() {
		return "../ssd/cadastrarCategoriaProblema.xhtml?faces-redirect=true";
	}
	
	public String newCategoriaProblema() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		CategoriaProblemaMB categoriaProblemaMB = (CategoriaProblemaMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "categoriaProblemaMB");
		categoriaProblemaMB.novo();
		return "../ssd/cadastrarCategoriaProblema.xhtm?faces-redirect=true";
	}
	
	public String equipamento() {
		return "../ssd/cadastrarEquipamento.xhtml?faces-redirect=true";
	}
	
	public String newEquipamento() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		EquipamentoMB equipamentoMB = (EquipamentoMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "equipamentoMB");
		equipamentoMB.novo();
		return "../ssd/cadastrarEquipamento.xhtml?faces-redirect=true";
	}
	
	public String incidente() {
		return "../ssd/cadastrarIncidente.xhtml?faces-redirect=true";
	}
	
	public String newIncidente() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		IncidenteMB incidenteMB = (IncidenteMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "incidenteMB");
		incidenteMB.novo();
		return "../ssd/cadastrarIncidente.xhtml?faces-redirect=true";
	}
	
	public String problema() {
		return "../ssd/cadastrarProblema.xhtml?faces-redirect=true";
	}
	
	public String newProblema() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		ProblemaMB problemaMB = (ProblemaMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "problemaMB");
		problemaMB.novo();
		return "../ssd/cadastrarProblema.xhtml?faces-redirect=true";
	}
	
	public String servidor() {
		return "../ssd/cadastrarServidor.xhtml?faces-redirect=true";
	}
	
	public String newServidor() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		ServidorMB servidorMB = (ServidorMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "servidorMB");
		servidorMB.novo();
		return "../ssd/cadastrarServidor.xhtml?faces-redirect=true";
	}
	
	public String solucaoProblema() {
		return "../ssd/cadastrarSolucaoProblema.xhtml?faces-redirect=true";
	}
	
	public String newSolucaoProblema() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		SolucaoProblemaMB solucaoProblemaMB = (SolucaoProblemaMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "solucaoProblemaMB");
		solucaoProblemaMB.novo();
		return "../ssd/cadastrarSolucaoProblema.xhtml?faces-redirect=true";
	}
	
	public String tipoEquipamento() {
		return "../ssd/cadastrarTipoEquipamento.xhtml?faces-redirect=true";
	}
	
	public String newTipoEquipamento() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		TipoEquipamentoMB tipoEquipamentoMB = (TipoEquipamentoMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "tipoEquipamentoMB");
		tipoEquipamentoMB.novo();
		return "../ssd/cadastrarTipoEquipamento.xhtml?faces-redirect=true";
	}
	
	public String classeProblema() {
		return "../admin/cadastrarClasseProblema.xhtml?faces-redirect=true";
	}
	
	public String newClasseProblema() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		ClasseProblemaMB classeProblemaMB = (ClasseProblemaMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "classeProblemaMB");
		classeProblemaMB.novo();
		return "../admin/cadastrarClasseProblema.xhtm?faces-redirect=true";
	}
	
	public String grupoUsuario() {
		return "../admin/cadastrarGrupoUsuario.xhtml?faces-redirect=true";
	}
	
	public String newGrupoUsuario() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		GrupoUsuarioMB grupoUsuarioMB = (GrupoUsuarioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "grupoUsuarioMB");
		grupoUsuarioMB.novo();
		return "../admin/cadastrarGrupoUsuario.xhtm?faces-redirect=true";
	}
	
	public String grupoUsuarioPredio() {
		return "../admin/cadastrarGrupoUsuarioPredio.xhtml?faces-redirect=true";
	}
	
	
	public String newGrupoUsuarioPredio() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		GrupoUsuarioPredioMB grupoUsuarioPredioMB = (GrupoUsuarioPredioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "grupoUsuarioPredioMB");
		grupoUsuarioPredioMB.novo();
		return "../admin/cadastrarGrupoUsuarioPredio.xhtm?faces-redirect=true";
	}
	
	public String nivel() {
		return "../admin/cadastrarNivel.xhtml?faces-redirect=true";
	}
	
	public String newNivel() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		NivelMB nivelMB = (NivelMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "nivelMB");
		nivelMB.novo();
		return "../admin/cadastrarNivel.xhtml?faces-redirect=true";
	}
	
	public String nivelSetor() {
		return "../admin/cadastrarNivelSetor.xhtml?faces-redirect=true";
	}
	
	public String newNivelSetor() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		NivelSetorMB nivelSetorMB = (NivelSetorMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "nivelSetorMB");
		nivelSetorMB.novo();
		return "../admin/cadastrarNivelSetor.xhtml?faces-redirect=true";
	}
	
	public String predio() {
		return "../admin/cadastrarPredio.xhtml?faces-redirect=true";
	}
	
	public String newPredio() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		PredioMB predioMB = (PredioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "predioMB");
		predioMB.novo();
		return "../admin/cadastrarPredio.xhtml?faces-redirect=true";
	}
	
	public String ramal() {
		return "../admin/cadastrarRamal.xhtml?faces-redirect=true";
	}
	
	public String newRamal() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		RamalMB ramalMB = (RamalMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "ramalMB");
		ramalMB.novo();
		return "../admin/cadastrarRamal.xhtml?faces-redirect=true";
	}
	
	public String sequenciaAtendimento() {
		return "../admin/cadastrarSequenciaAtendimento.xhtml?faces-redirect=true";
	}
	
	public String newSequenciaAtendimento() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		SequenciaAtendimentoMB sequenciaAtendimentoMB = (SequenciaAtendimentoMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "sequenciaAtendimentoMB");
		sequenciaAtendimentoMB.novo();
		return "../admin/cadastrarSequenciaAtendimento.xhtml?faces-redirect=true";
	}
	
	public String setor() {
		return "../admin/cadastrarSetor.xhtml?faces-redirect=true";
	}
	
	public String newSetor() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		SetorMB setorMB = (SetorMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "setorMB");
		setorMB.novo();
		return "../admin/cadastrarSetor.xhtml?faces-redirect=true";
	}
	
	public String statusIncidente() {
		return "../admin/cadastrarStatusIncidente.xhtml?faces-redirect=true";
	}
	
	public String usuario() {
		return "../admin/cadastrarUsuario.xhtml?faces-redirect=true";
	}
	
	public String newUsuario() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		UsuarioMB usuarioMB = (UsuarioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "usuarioMB");
		usuarioMB.novo();
		return "../admin/cadastrarUsuario.xhtml?faces-redirect=true";
	}
	
	public String registrarIncidente() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		UsuarioMB usuarioMB = (UsuarioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "usuarioMB");
		usuarioMB.novo();
		RegistroIncidenteMB registroIncidenteMB = (RegistroIncidenteMB) FacesContext.getCurrentInstance().getApplication()
			    .getELResolver().getValue(elContext, null, "registroIncidenteMB");
		registroIncidenteMB.novo();
		
		return "../ssd/registrarIncidente.xhtml?faces-redirect=true";
	}
	
	public String incidentesAgDesig() {
		return "../sapc/listarIncidentesAgDesig.xhtml?faces-redirect=true";
	}
	
	public String incidentesAgEnc() {
		return "../sapc/listarIncidentesAgEnc.xhtml?faces-redirect=true";
	}
	
	public String incidentesAgAtendSAPC() {
		return "../sapc/listarIncidentesAgAtendSAPC.xhtml?faces-redirect=true";
	}
	
	public String visualizarIncidente() {
		return "../sapc/visualizarIncidente.xhtml?faces-redirect=true";
	}
	
	public String designarIncidente() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		RegistroIncidenteMB registroIncidenteMB = (RegistroIncidenteMB) FacesContext.getCurrentInstance().getApplication()
			    .getELResolver().getValue(elContext, null, "registroIncidenteMB");
		UsuarioMB usuarioMB = (UsuarioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "usuarioMB");
		System.out.println("Servidor: "+registroIncidenteMB.getRegistroIncidente().getIncidente().getServidor().getNome());
		usuarioMB.setServidor(registroIncidenteMB.getRegistroIncidente().getIncidente().getServidor());
		return "../sapc/designarIncidente.xhtml?faces-redirect=true";
	}
	
	public String designarIncidenteSAPC() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		RegistroIncidenteMB registroIncidenteMB = (RegistroIncidenteMB) FacesContext.getCurrentInstance().getApplication()
			    .getELResolver().getValue(elContext, null, "registroIncidenteMB");
		UsuarioMB usuarioMB = (UsuarioMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "usuarioMB");
		System.out.println("Servidor: "+registroIncidenteMB.getRegistroIncidente().getIncidente().getServidor().getNome());
		usuarioMB.setServidor(registroIncidenteMB.getRegistroIncidente().getIncidente().getServidor());
		return "../sapc/designarIncidenteSAPC.xhtml?faces-redirect=true";
	}
	
	public String incidentesDesignados() {
		return "../sapc/listarIncidentesDesig.xhtml?faces-redirect=true";
	}
	
	public String incidentesDesignadosSAPC() {
		return "../sapc/listarIncidentesDesigSAPC.xhtml?faces-redirect=true";
	}
	
	public String incidentesAutorizada() {
		return "../sapc/listarIncidentesAgRetorno.xhtml?faces-redirect=true";
	}
	
	public String trocarEquipamento() {
		ELContext elContext = FacesContext.getCurrentInstance().getELContext();
		RegistroIncidenteMB registroIncidenteMB = (RegistroIncidenteMB) FacesContext.getCurrentInstance().getApplication()
			    .getELResolver().getValue(elContext, null, "registroIncidenteMB");
		IncidenteMB incidenteMB = (IncidenteMB) FacesContext.getCurrentInstance().getApplication()
		    .getELResolver().getValue(elContext, null, "incidenteMB");
		//System.out.println("Servidor: "+registroIncidenteMB.getRegistroIncidente().getIncidente().getServidor().getNome());
		incidenteMB.setIncidente(registroIncidenteMB.getRegistroIncidente().getIncidente());
		return "../sapc/trocarEquipamento.xhtml?faces-redirect=true";
	}
}
